package com.yodawnla.zombieCity.scene;

import org.anddev.andengine.entity.scene.background.SpriteBackground;
import org.anddev.andengine.entity.sprite.Sprite;

import android.view.KeyEvent;

import com.yodawnla.lib.YoScene;
import com.yodawnla.lib.util.widget.YoButton;
import com.yodawnla.zombieCity.system.SE;
import com.yodawnla.zombieCity.system.Tex;
import com.yodawnla.zombieCity.system.Values;

public class TitleScene extends YoScene
{
	@Override
	public void loadScene()
	{
		SpriteBackground bg = new SpriteBackground(new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT, getTexture(Tex.bg)));
		mScene.setBackground(bg);
		
		YoButton start = new YoButton(this, 20, 430, getTexture(Tex.button))
		{
			@Override
			public void onClickedEvent()
			{
				playSound(SE.Click);
				toScene("GameScene");
			}
		};
		mScene.attachChild(start);
	}
	
	@Override
	public void onEnterScene()
	{
		((GameScene)TitleScene.this.getYoScene("GameScene")).getClient().sendMesg(Values.Server.MAP);
	}
	
	@Override
	public void onExitScene()
	{
		
	}
	
	@Override
	public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) 
	{
		if(pKeyCode == KeyEvent.KEYCODE_BACK && pEvent.getAction() == KeyEvent.ACTION_DOWN)
		{
			playSound("SeClick");
			return true;
		}
		return false;
	}
}